Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preserve Android MediaPlayer paused prop when backgrounding #1082

Merged
merged 1 commit into from
Jun 22, 2018

Conversation

cobarx
Copy link
Contributor

@cobarx cobarx commented Jun 22, 2018

This allows users to set paused when they detect a background event so that when you return to the app, the video is paused.

Example:

state = {
  paused: false
}

componentDidMount() {
  AppState.addEventListener('change', this.onAppStateChange);
}

onAppStateChange = change => {
  if (change === 'background') {
    this.setState({ paused: true });
  }
}

render() {
  return <Video style={...} source={...} paused={this.state.paused} />;
}

This allows users to set paused when they detect a background event so that when you return to the app, the video is paused.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant